/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * vwBeginScherm.java
 *
 * Created on 18-mei-2011, 13:09:42
 */
package tcnplanner;

/**
 *
 * @author Koen
 */
public class vwBeginScherm extends javax.swing.JPanel {

    /** Creates new form vwBeginScherm */
    public vwBeginScherm(Controller.ActorType actor){
        initComponents();
        this.plEngineer.setVisible(false);
        this.plKlant.setVisible(false);
        this.plOperator.setVisible(false);
        this.plPlanner.setVisible(false);
        switch(actor){
            case INTERNCUSTOMER:
                this.plKlant.setVisible(true);
                break;
            case EXTERNCUSTOMER:
                this.plKlant.setVisible(true);
                break;
            case PLANNER:
                this.plPlanner.setVisible(true);
                break;
            case OPERATOR:
                this.plOperator.setVisible(true);
                break;
            case ENGINEER:
                this.plEngineer.setVisible(true);
                break;
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        plKlant = new javax.swing.JPanel();
        vwKlant1 = new tcnplanner.vwKlant();
        lbStartpagina = new javax.swing.JLabel();
        plEngineer = new javax.swing.JPanel();
        vwEngineer1 = new tcnplanner.vwEngineer();
        plOperator = new javax.swing.JPanel();
        vwOperator1 = new tcnplanner.vwOperator();
        btLogout = new javax.swing.JButton();
        plPlanner = new javax.swing.JScrollPane();
        vwPlanner1 = new tcnplanner.vwPlanner();

        setBackground(java.awt.SystemColor.inactiveCaption);

        plKlant.setBackground(java.awt.SystemColor.inactiveCaption);
        plKlant.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        plKlant.setName("plKlant"); // NOI18N

        vwKlant1.setName("vwKlant1"); // NOI18N

        javax.swing.GroupLayout plKlantLayout = new javax.swing.GroupLayout(plKlant);
        plKlant.setLayout(plKlantLayout);
        plKlantLayout.setHorizontalGroup(
            plKlantLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(plKlantLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(vwKlant1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(302, Short.MAX_VALUE))
        );
        plKlantLayout.setVerticalGroup(
            plKlantLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(plKlantLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(vwKlant1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(43, Short.MAX_VALUE))
        );

        lbStartpagina.setText("Start pagina");
        lbStartpagina.setName("lbStartpagina"); // NOI18N

        plEngineer.setBackground(java.awt.SystemColor.inactiveCaption);
        plEngineer.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        plEngineer.setName("plEngineer"); // NOI18N

        vwEngineer1.setName("vwEngineer1"); // NOI18N

        javax.swing.GroupLayout plEngineerLayout = new javax.swing.GroupLayout(plEngineer);
        plEngineer.setLayout(plEngineerLayout);
        plEngineerLayout.setHorizontalGroup(
            plEngineerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(plEngineerLayout.createSequentialGroup()
                .addComponent(vwEngineer1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(460, Short.MAX_VALUE))
        );
        plEngineerLayout.setVerticalGroup(
            plEngineerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(plEngineerLayout.createSequentialGroup()
                .addComponent(vwEngineer1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(270, Short.MAX_VALUE))
        );

        plOperator.setBackground(java.awt.SystemColor.inactiveCaption);
        plOperator.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        plOperator.setName("plOperator"); // NOI18N

        vwOperator1.setName("vwOperator1"); // NOI18N

        javax.swing.GroupLayout plOperatorLayout = new javax.swing.GroupLayout(plOperator);
        plOperator.setLayout(plOperatorLayout);
        plOperatorLayout.setHorizontalGroup(
            plOperatorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(plOperatorLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(vwOperator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(152, Short.MAX_VALUE))
        );
        plOperatorLayout.setVerticalGroup(
            plOperatorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(plOperatorLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(vwOperator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(259, Short.MAX_VALUE))
        );

        btLogout.setText("Logout");
        btLogout.setName("btLogout"); // NOI18N
        btLogout.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btLogoutActionPerformed(evt);
            }
        });

        plPlanner.setName("plPlanner"); // NOI18N

        vwPlanner1.setName("vwPlanner1"); // NOI18N
        plPlanner.setViewportView(vwPlanner1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(lbStartpagina)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 1390, Short.MAX_VALUE)
                        .addComponent(btLogout))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(plEngineer, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(plKlant, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(6, 6, 6)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(plPlanner, javax.swing.GroupLayout.DEFAULT_SIZE, 600, Short.MAX_VALUE)
                            .addComponent(plOperator, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lbStartpagina)
                    .addComponent(btLogout))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(plPlanner)
                    .addComponent(plKlant, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(plOperator, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(plEngineer, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void btLogoutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btLogoutActionPerformed
        // TODO add your handling code here:
        setScreen(new vwLogin());
    }//GEN-LAST:event_btLogoutActionPerformed

    private void setScreen(java.awt.Component s) {
        java.awt.Component mainpl = null;
        if (this.getParent().getName().equals("plMainPanel")) {
            mainpl = this.getParent();
        } else {
            java.awt.Component p = this.getParent();
            while (p == null && p.getParent()!=null) {
                p = p.getParent();
                if (p.getName().equals("plMainPanel"))
                {
                    mainpl = p;
                }
            }
        }
        if (mainpl != null) {
            javax.swing.JPanel p = (javax.swing.JPanel) mainpl;
            p.removeAll();
            //SCREEN TYPE INFO
            java.awt.Component screen = s;
            //END OF SCREEN TYPE INFO
            javax.swing.GroupLayout plMainPanelLayout = new javax.swing.GroupLayout(p);
            p.setLayout(plMainPanelLayout);
            plMainPanelLayout.setHorizontalGroup(
                    plMainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(screen, javax.swing.GroupLayout.DEFAULT_SIZE, 800, Short.MAX_VALUE));
            plMainPanelLayout.setVerticalGroup(
                    plMainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(screen, javax.swing.GroupLayout.DEFAULT_SIZE, 600, Short.MAX_VALUE));
        }
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btLogout;
    private javax.swing.JLabel lbStartpagina;
    public javax.swing.JPanel plEngineer;
    public javax.swing.JPanel plKlant;
    public javax.swing.JPanel plOperator;
    private javax.swing.JScrollPane plPlanner;
    private tcnplanner.vwEngineer vwEngineer1;
    private tcnplanner.vwKlant vwKlant1;
    private tcnplanner.vwOperator vwOperator1;
    private tcnplanner.vwPlanner vwPlanner1;
    // End of variables declaration//GEN-END:variables
}
